package org.dubnation.auth.controller;

import org.dubnation.auth.domain.RoleVO;
import org.dubnation.auth.domain.User;
import org.dubnation.auth.service.ILoginService;
import org.dubnation.base.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private ILoginService service;

    /**
     * VO: View Object
     *     前端接受的参数和后端传递的参数差异较大
     * @param user
     * @return
     */
    @PostMapping
    public AjaxResult login(@RequestBody User user) {
        try {
            RoleVO empMessage =  service.login(user);
            return AjaxResult.success(empMessage);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error(e.getMessage());
        }
    }
}
